<?php 

defined('_JEXEC') or die('Restricted access');
		
$rows = $this->items[0];

global $mainframe;
$site =  $mainframe->getCfg('live_site');
$document = & JFactory::getDocument();
$sroot =  $_SERVER["DOCUMENT_ROOT"];
$document->addStyleSheet(str_replace($sroot ,'/',JRoute::_(JPATH_ROOT.DS.'components/com_totemtoo/css/upload.css')));
$document->addScript(str_replace($sroot ,'/',JRoute::_( JPATH_ROOT.DS.'components/com_totemtoo/script/script_upload.js')));

JHTML::calendar($rows->data_published, 'data_published', 'data_published', '%Y-%m-%d');
?>


<div class="col100">
	<fieldset class="adminform">
	<form action="index.php" method="post" name="adminForm" id="adminForm">
		<legend>
			<?php echo JText::_( 'Dettagli' ); ?>
		</legend>
		<table class="admintable">
		<tr>
			<td width="100" align="right" class="key">
				<label for="Indirizzo">
					<?php echo JText::_( 'Indirizzo' ); ?>:
				</label>
			</td>
			<td>
				<input class="text_area" type="text" name="indirizzo" id="Indirizzo" size="70" maxlength="250" value="<?php echo $rows->indirizzo; ?>" />
			</td>
		</tr>
		<tr>
			<td width="100" align="right" class="key">
				<label for="Comune">
					<?php echo JText::_( 'Comune' ); ?>:
				</label>
			</td>
			<td>
<!--				<input class="text_area" type="text" name="comune" id="Comune" size="70" maxlength="250" value="<?php /* echo $rows->comune; */ echo $this->nomeComune; ?>" />  -->
        <select name='comune' id="Comune" >
     	         <option selected VALUE='<?php echo $rows->comune; ?>'><?php 
	             echo $this->nomeComune; 
	 ?> 
	 </option>
     <?php 
     $database = &JFactory::GetDBO();
     $database->setQuery("SELECT P.Prv_Sigla, C.Com_Provincia, C.Com_Codice, C.Com_Nome FROM #__TotemToo_Comuni C, #__TotemToo_Provincie P, #__TotemToo_Regioni R WHERE (R.Reg_Descr ='MARCHE' AND P.Prv_CodRegione = R.Reg_Codice AND C.Com_Provincia = P.Prv_Codice) ORDER BY Com_Provincia, Com_Nome;");  
     $oggetto = $database->loadAssocList();
     foreach ($oggetto as $riga) {
       $CodiceComune = $riga['Com_Provincia'].$riga['Com_Codice'];
       $var = $riga['Prv_Sigla']." - ".$riga['Com_Nome'];
       echo "<option value='".$CodiceComune. "' >".$var."</option>";
     }
     echo "</select>"; ?>
			</td>
		<tr>
			<td width="100" align="right" class="key">
				<label for="descrizione">
					<?php echo JText::_( 'Descrizione' ); ?>:
				</label>
			</td>
			<td>
				<textarea class="text_area" type="textarea" name="descrizione" id="descrizione" rows="5" cols="60"><?php echo $rows->descrizione;?></textarea>
			</td>
		</tr>
		<tr>
			<td width="100" align="right" class="key">
				<label for="prezzo">
					<?php echo JText::_( 'Prezzo' ); ?>:
				</label>
			</td>
			<td>
				<textarea class="text_area" type="text" name="prezzo" id="prezzo" size="70" maxlength="250"><?php echo $rows->prezzo; ?></textarea>
			</td>
		</tr>
		<tr>
			<td width="100" align="right" class="key">
				<label for="operazione">
					<?php echo JText::_( 'Tipo Operazione' ); ?>:
				</label>
			</td>
			<td>
				<textarea class="text_area" type="text" name="operazione" id="operazione" size="70" maxlength="250"><?php echo $rows->operazione; ?></textarea>
			</td>
		</tr>
		<tr>
			<td width="100" align="right" class="key">
				<label for="tipo_imm">
					<?php echo JText::_( 'Tipo Immobile' ); ?>:
				</label>
			</td>
			<td>
				<textarea class="text_area" type="text" name="tipo_imm" id="tipo_imm" size="70" maxlength="250"><?php echo $rows->tipo_imm; ?></textarea>
			</td>
		</tr>
		<tr>
			<td width="100" align="right" class="key">
				<label for="data_published">
					<?php echo JText::_( 'Data Pubblicazione' ); ?>:
				</label>
			</td>
			<td>
					<input type="text"  name="data_published" id="data_published" value="<?php echo $rows->data_published; ?>" />
			</td>
		</tr>
		</table>
	<div class="clr"></div>
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="option" value="com_totemtoo" />
	<input type="hidden" name="id" value="<?php echo $rows->id; ?>" />
		</form>
		<hr>
		<?php
			if ($rows->id) {
		?>
			<form enctype="multipart/form-data" name="form_upload" id="form_upload" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="POST">
				<table class="admintable">
				<tr>
					<td width="100" align="right" class="key">
						<label for="immagine">
							<?php echo JText::_( 'Immagine' ); ?>:
						</label>
					</td><td>
						<input type="file"  name="file" />
						<?php
							if ($this->imm_caricata) {
						?>
						<div><img src="<?php echo $this->imm_caricata; ?>" WIDTH="300" ALIGN="center" border="1" alt="Immagine <?php  echo $this->imm_nome; ?>" /></div>
						<?php
							} else {
							echo '<B>Immagine NON CARICATA!</B>';
							}
						?>
						<br/>
						<input type="submit" name="sub_upload" value="Upload!"/>
					</td>
				</tr>
				</table>
			</form>
		
		<?php
			}
		?>
	
</fieldset>
</div>
